home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 2 / BBS in a box - Trilogy II.iso / Files / Game / F-G / Glypha II 1.1 ƒ / Glypha II 1.1 Source Code ƒ / Code ƒ / F-GlyphaGuts.p < prev    next >
Encoding:
Text File  |  1991-05-18  |  20.2 KB  |  766 lines  |  [TEXT/PJMM]

  1. unit GlyphaGuts;
  2.  
  3. interface
  4.     uses
  5.         Palettes, Dialogs, Sound, Globals, Enemies, GameUtils;
  6.  
  7.     procedure DoAStoneHit (whichStone: Rect);
  8.     procedure MoveThePlayer;
  9.     procedure CheckTombStones;
  10.     procedure AnimateTheAnk;
  11.     procedure AdvanceALevel;
  12.     procedure EnterANewMortal;
  13.     procedure DoEnd;
  14.     procedure ExitAMortal;
  15.     procedure SlideTheStones;
  16.  
  17. implementation
  18.  
  19. {=================================}
  20.  
  21.     procedure DoOnTheGround;
  22.         var
  23.             onLand: Boolean;
  24.             index: Integer;
  25.             tempRect, dummyRect: Rect;
  26.     begin
  27.         with thePlayer do
  28.             begin
  29.                 if (state) then        {taking off from the ground}
  30.                     begin
  31.                         DoTheSound('flap.snd', lowPriority);
  32.                         state := FALSE;
  33.                         mode := 5;
  34.                         ChangeRect;
  35.                         vertVel := liftAmount;
  36.                     end
  37.                 else                            {but if not flapping...}
  38.                     begin
  39.                         onLand := FALSE;
  40.                         tempRect := dest;
  41.                         InsetRect(tempRect, 17, 0);
  42.                         OffsetRect(tempRect, 0, 2);
  43.                         for index := startStone to numberOfStones do
  44.                             if (SectRect(tombRects[index], tempRect, dummyRect)) then
  45.                                 onLand := TRUE;
  46.                         if not onLand then
  47.                             begin
  48.                                 mode := 4;
  49.                                 ChangeRect;
  50.                                 vertVel := fallAmount;
  51.                             end
  52.                         else                            {on solid ground}
  53.                             begin
  54.                                 if (keyStillDown) then    {and running}
  55.                                     begin
  56.                                         horiVel := running[horiVel, facing, 0];
  57.                                         mode := running[horiVel, facing, 1];
  58.                                         if ((mode = 0) or (mode = 2)) then
  59.                                             DoTheSound('walk.snd', lowPriority);
  60.                                     end
  61.                                 else                            {not running, we're braking - screeeech}
  62.                                     begin
  63.                                         mode := 1;
  64.                                         horiVel := idleLanded[horiVel];
  65.                                         if (horiVel <> 0) then
  66.                                             DoTheSound('screech.snd', lowPriority);
  67.                                     end;                        {end - else, key still down}
  68.                             end;                            {end - else, not on solid ground}
  69.                     end;                                {end - else, not flapping to take off}
  70.                 dest.left := dest.left + horiVel;
  71.                 dest.right := dest.right + horiVel;
  72.                 dest.top := dest.top + vertVel;
  73.                 dest.bottom := dest.bottom + vertVel;
  74.             end;
  75.     end;
  76.  
  77. {=================================}
  78.  
  79.     procedure DoAStoneHit;
  80.     begin
  81.         with thePlayer do
  82.             begin
  83.                 if (horiVel > 0) then
  84.                     begin
  85.                         if (dest.left < whichStone.left) then    {hit the edge}
  86.                             begin
  87.                                 dest.left := dest.left + whichStone.left - whichStone.right;
  88.                                 dest.right := dest.right + whichStone.left - whichStone.right;
  89.                                 horiVel := impacted[horiVel];
  90.                             end
  91.                         else
  92.                             begin
  93.                                 if (vertVel < 0) then                            {hit coming up}
  94.                                     begin
  95.                                         vertVel := impacted[vertVel];
  96.                                         OffsetRect(dest, 0, whichStone.bottom - dest.top);
  97.                                     end
  98.                                 else
  99.                                     begin
  100.                                         if (mode = 6) then
  101.                                             begin
  102.                                                 DoTheSound('boom1.snd', highPriority);
  103.                                                 OffsetRect(dest, 0, whichStone.top - dest.bottom);
  104.                                                 vertVel := 0;
  105.                                                 horiVel := 0;
  106.                                                 mode := 50;
  107.                                                 ChangeRect;
  108.                                                 Exit(DoAStoneHit);
  109.                                             end;
  110.                                         if (vertVel < 4) or (dest.right > whichStone.right) then
  111.                                             begin
  112.                                                 DoTheSound('screech.snd', lowPriority);
  113.                                                 vertVel := -3;
  114.                                                 OffSetRect(dest, 0, whichStone.top - dest.bottom);
  115.                                             end
  116.                                         else
  117.                                             begin
  118.                                                 DoTheSound('walk.snd', lowPriority);
  119.                                                 vertVel := 0;
  120.                                                 OffSetRect(dest, 0, whichStone.top - dest.bottom - 10);
  121.                                                 mode := 1;
  122.                                                 ChangeRect;
  123.                                             end;
  124.                                     end;
  125.                             end;
  126.                     end
  127.                 else
  128.                     begin
  129.                         if (dest.right > whichStone.right) then    {hit the edge}
  130.                             begin
  131.                                 OffsetRect(dest, whichStone.right - whichStone.left, 0);
  132.                                 horiVel := impacted[horiVel];
  133.                             end
  134.                         else
  135.                             begin
  136.                                 if (vertVel < 0) then        {hit coming up}
  137.                                     begin
  138.                                         vertVel := impacted[vertVel];
  139.                                         OffsetRect(dest, 0, whichStone.bottom - dest.top);
  140.                                     end
  141.                                 else
  142.                                     begin
  143.                                         if (mode = 6) then
  144.                                             begin
  145.                                                 DoTheSound('boom1.snd', highPriority);
  146.                                                 OffsetRect(dest, 0, whichStone.top - dest.bottom);
  147.                                                 vertVel := 0;
  148.                                                 horiVel := 0;
  149.                                                 if (mortals <= 1) then
  150.                                                     mode := 7
  151.                                                 else
  152.                                                     mode := 50;
  153.                                                 ChangeRect;
  154.                                                 Exit(DoAStoneHit);
  155.                                             end;
  156.                                         if (vertVel < 4) or (dest.left < whichStone.left) then
  157.                                             begin
  158.                                                 DoTheSound('screech.snd', lowPriority);
  159.                                                 vertVel := -3;
  160.                                                 OffSetRect(dest, 0, whichStone.top - dest.bottom);
  161.                                             end
  162.                                         else
  163.                                             begin
  164.                                                 DoTheSound('walk.snd', lowPriority);
  165.                                                 vertVel := 0;
  166.                                                 OffSetRect(dest, 0, whichStone.top - dest.bottom - 10);
  167.                                                 mode := 1;
  168.                                                 ChangeRect;
  169.                                             end;
  170.                                     end;
  171.                             end;
  172.                     end;
  173.             end;
  174.     end;
  175.  
  176. {=================================}
  177.  
  178.     procedure DoInTheAir;
  179.         var
  180.             index: Integer;
  181.             tempRect, dummyRect: Rect;
  182.     begin
  183.         with thePlayer do
  184.             begin
  185.                 if (keyStillDown) then
  186.                     horiVel := gliding[horiVel, facing];
  187.                 if (state) then
  188.                     begin
  189.                         DoTheSound('flap.snd', lowPriority);
  190.                         mode := 5;
  191.                         state := FALSE;
  192.                         vertVel := vertVel + liftAmount;
  193.                     end
  194.                 else
  195.                     begin
  196.                         if (vertVel < maxFall) then
  197.                             vertVel := vertVel + fallAmount;
  198.                         if (vertVel > 0) then
  199.                             mode := 4
  200.                         else
  201.                             mode := 5;
  202.                     end;
  203.                 dest.left := dest.left + horiVel;
  204.                 dest.right := dest.right + horiVel;
  205.                 dest.top := dest.top + vertVel;
  206.                 dest.bottom := dest.bottom + vertVel;
  207.                 for index := startStone to numberOfStones do
  208.                     begin
  209.                         if SectRect(dest, tombRects[index], dummyRect) then
  210.                             DoAStoneHit(dummyRect);
  211.                     end;
  212.             end;
  213.     end;
  214.  
  215. {=================================}
  216.  
  217.     procedure DoFallingSkeleton;
  218.         var
  219.             index: Integer;
  220.             dummyRect: Rect;
  221.     begin
  222.         with thePlayer do
  223.             begin
  224.                 if (vertVel < maxFall) then
  225.                     vertVel := vertVel + fallAmount;
  226.                 dest.left := dest.left + horiVel;
  227.                 dest.right := dest.right + horiVel;
  228.                 dest.top := dest.top + vertVel;
  229.                 dest.bottom := dest.bottom + vertVel;
  230.                 for index := startStone to numberOfStones do
  231.                     begin
  232.                         if SectRect(dest, tombRects[index], dummyRect) then
  233.                             DoAStoneHit(dummyRect);
  234.                     end;
  235.             end;
  236.     end;
  237.  
  238. {=================================}
  239.  
  240.     procedure DoDeadBones;
  241.     begin
  242.         with thePlayer do
  243.             begin
  244.                 if (mode < 8) then
  245.                     begin
  246.                         OffsetRect(dest, 0, 1);
  247.                         dest.bottom := dest.bottom - 1;
  248.                         if (dest.bottom = dest.top) then
  249.                             begin
  250.                                 deadAndGone := TRUE;
  251.                                 CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, dest, dest, srcCopy, playRgn);
  252.                             end;
  253.                     end
  254.                 else
  255.                     mode := mode - 1;
  256.             end;
  257.     end;
  258.  
  259. {=================================}
  260.  
  261.     procedure MoveThePlayer;
  262.  
  263.     begin
  264.         case thePlayer.mode of
  265.             0..3: 
  266.                 begin
  267.                     DoOnTheGround;
  268.                     CheckTombStones;
  269.                 end;
  270.             4..5: 
  271.                 begin
  272.                     DoInTheAir;
  273.                     CheckTombStones;
  274.                 end;
  275.             6: 
  276.                 begin
  277.                     DoFallingSkeleton;
  278.                     CheckTombStones;
  279.                 end;
  280.             7..100: 
  281.                 DoDeadBones;
  282.         end;
  283.     end;
  284.  
  285. {=================================}
  286.  
  287.     procedure CheckTombStones;
  288.         var
  289.             hori, vert: Integer;
  290.             dummyRect: Rect;
  291.  
  292. {-------------------}
  293.  
  294.         procedure TooLow;
  295.         begin
  296.             with thePlayer do
  297.                 if (otherState) then
  298.                     begin
  299.                         OffsetRect(dest, 0, 1);
  300.                         if (dest.top > playRect.bottom + 10) then
  301.                             deadAndGone := TRUE;
  302.                         Exit(CheckTombStones);
  303.                     end
  304.                 else
  305.                     begin
  306.                         DoTheSound('bird.snd', highPriority);
  307.                         OffsetRect(dest, 0, playRect.bottom - dest.top + 1);
  308.                         otherState := TRUE;
  309.                         Exit(CheckTombStones);
  310.                     end;
  311.         end;
  312.  
  313.  
  314. {-------------------}
  315.  
  316.         procedure TooHi;
  317.         begin
  318.             with thePlayer do
  319.                 begin
  320.                     vertVel := impacted[vertVel];
  321.                     OffSetRect(dest, 0, playRect.top - dest.bottom + 1);
  322.                 end;
  323.         end;
  324.  
  325. {-------------------}
  326.  
  327.         procedure TooLeft;
  328.         begin
  329.             with thePlayer do
  330.                 begin
  331.                     CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, oldDest, oldDest, srcCopy, playRgn);
  332.                     OffsetRect(dest, 640, 0);
  333.                     oldDest := dest;
  334.                 end;
  335.         end;
  336.  
  337. {-------------------}
  338.  
  339.         procedure TooRight;
  340.         begin
  341.             with thePlayer do
  342.                 begin
  343.                     CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, oldDest, oldDest, srcCopy, playRgn);
  344.                     OffsetRect(dest, -640, 0);
  345.                     oldDest := dest;
  346.                 end;
  347.         end;
  348.  
  349. {-------------------}
  350.  
  351.     begin
  352.         with thePlayer do
  353.             if (not SectRect(dest, playRect, dummyRect)) then    {Player has left the screen    }
  354.                 begin
  355.                     if (dest.top > playRect.bottom) then
  356.                         TooLow;
  357.                     if (dest.bottom <= playRect.top) then
  358.                         TooHi;
  359.                     if (dest.right < playRect.left) then
  360.                         TooLeft;
  361.                     if (dest.left > playRect.right) then
  362.                         TooRight;
  363.                 end;
  364.     end;
  365.  
  366. {=================================}
  367.  
  368.     procedure AnimateTheAnk;
  369.         var
  370.             index, index2, howHigh: Integer;
  371.             dummyLong, loopDelay: LongInt;
  372.             newRect, tempRect: Rect;
  373.             theKeys: KeyMap;
  374.     begin
  375.         DoTheSound('lightning.snd', highPriority);
  376.         if ((numberOfStones > 4) and (DoRandom(2) = 0) and (not stonesSliding)) then
  377.             begin
  378.                 newRect := playerRects[0, 0];
  379.                 OffsetRect(newRect, -newRect.left - 24, -newRect.top);
  380.                 OffsetRect(newRect, 320, tombRects[5].top - newRect.bottom);
  381.                 howHigh := upperLevel;
  382.                 thePlayer.dest := newRect;
  383.                 thePlayer.oldDest := thePlayer.dest;
  384.             end
  385.         else
  386.             begin
  387.                 newRect := playerRects[0, 0];
  388.                 OffsetRect(newRect, -newRect.left - 24, -newRect.top);
  389.                 OffsetRect(newRect, 320, tombRects[0].top - newRect.bottom);
  390.                 howHigh := lowerLevel;
  391.                 thePlayer.dest := newRect;
  392.                 thePlayer.oldDest := thePlayer.dest;
  393.             end;
  394.         newRect.left := newRect.left + 10;
  395.         newRect.right := newRect.left + 16;
  396.         newRect.top := newRect.bottom - 23;
  397.  
  398.         CopyMask(BitMapPtr(objectCPtr^.portPixMap^)^, offMaskMap, mainWndo^.portBits, ankRects[0], ankRects[0], newRect);
  399.         StrikeLightning(howHigh);
  400.         StrikeLightning(howHigh);
  401.         StrikeLightning(howHigh);
  402.  
  403.         tempRect := thePlayer.dest;
  404.         FlushEvents(everyEvent, 0);
  405.  
  406.         loopDelay := TickCount + gameSpeed;
  407.         for index := 0 to 60 do        {Here's where the player flashes in get-ready mode    }
  408.             begin
  409.                 DoTheSound('rez.snd', highPriority);
  410.                 CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, BitMapPtr(loadCPtr^.portPixMap^)^, tempRect, tempRect, srcCopy, nil);
  411.                 CopyMask(BitMapPtr(objectCPtr^.portPixMap^)^, offMaskMap, BitMapPtr(loadCPtr^.portPixMap^)^, ankRects[0], ankRects[0], newRect);
  412.                 CopyBits(BitMapPtr(loadCPtr^.portPixMap^)^, mainWndo^.portBits, tempRect, tempRect, srcCopy, nil);
  413.                 if (stonesSliding) then
  414.                     SlideTheStones;
  415.                 UpdateEye;
  416.                 HandleTheEnemies;
  417.                 DrawBeasts;
  418.                 repeat
  419.                     GetKeys(theKeys);
  420.                     if (theKeys[kSpaceKey] or Button) then
  421.                         begin
  422.                             thePlayer.otherState := FALSE;
  423.                             FlushEvents(everyEvent, 0);
  424.                             Exit(AnimateTheAnk);
  425.                         end;
  426.                 until (TickCount >= loopDelay);
  427.                 loopDelay := TickCount + gameSpeed;
  428.  
  429.                 CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, BitMapPtr(loadCPtr^.portPixMap^)^, newRect, newRect, srcCopy, nil);
  430.                 CopyMask(BitMapPtr(objectCPtr^.portPixMap^)^, offMaskMap, BitMapPtr(loadCPtr^.portPixMap^)^, playerRects[0, 1], playerRects[0, 1], tempRect);
  431.                 CopyBits(BitMapPtr(loadCPtr^.portPixMap^)^, mainWndo^.portBits, tempRect, tempRect, srcCopy, nil);
  432.  
  433.                 if (stonesSliding) then
  434.                     SlideTheStones;
  435.                 UpdateEye;
  436.                 HandleTheEnemies;
  437.                 if (theHand.state) then
  438.                     RetractTheHand;
  439.                 DrawBeasts;
  440.                 repeat
  441.                     GetKeys(theKeys);
  442.                     if (theKeys[kSpaceKey] or Button) then
  443.                         begin
  444.                             thePlayer.otherState := FALSE;
  445.                             FlushEvents(everyEvent, 0);
  446.                             Exit(AnimateTheAnk);
  447.                         end;
  448.                 until (TickCount >= loopDelay);
  449.                 loopDelay := TickCount + gameSpeed;
  450.             end;
  451.         thePlayer.otherState := FALSE;
  452.         FlushEvents(everyEvent, 0);
  453.     end;
  454.  
  455. {=================================}
  456.  
  457.     procedure AdvanceALevel;
  458.         var
  459.             index, aNumber, anotherNumber: Integer;
  460.  
  461. {--------------------}
  462.  
  463.         procedure SetUpEggEnemies;
  464.             var
  465.                 index: Integer;
  466.         begin
  467.             totalToKill := 6;
  468.             numberOfEnemies := 6;
  469.             beastsActive := 6;
  470.             for index := 1 to numberOfEnemies do
  471.                 with theEnemies[index] do
  472.                     begin
  473.                         mode := -DoRandom(kEggDelayRange) + (levelOn * kEggLevelPenalty);
  474.                         if (mode > -100) then
  475.                             mode := DoRandom(50) - 150;
  476.                         otherState := TRUE;
  477.                         facing := DoRandom(2);
  478.                         aNumber := DoRandom(2);                    {Now we figure out where the sphinx is    }
  479.                         anotherNumber := DoRandom(110) + 20;    {to appear.  What platform, what side.}
  480.                         if (facing = 0) then
  481.                             begin
  482.                                 if aNumber = 0 then
  483.                                     begin
  484.                                         dest := eggRects;
  485.                                         anotherNumber := anotherNumber - (dest.right - dest.left);
  486.                                         OffsetRect(dest, -dest.left, -dest.bottom);
  487.                                         OffsetRect(dest, tombRects[3].right - anotherNumber, tombRects[3].top);
  488.                                     end
  489.                                 else
  490.                                     begin
  491.                                         dest := eggRects;
  492.                                         anotherNumber := anotherNumber - (dest.right - dest.left);
  493.                                         OffsetRect(dest, -dest.left, -dest.bottom);
  494.                                         OffsetRect(dest, tombRects[1].right - anotherNumber, tombRects[1].top);
  495.                                     end;
  496.                             end
  497.                         else
  498.                             begin
  499.                                 if aNumber = 0 then
  500.                                     begin
  501.                                         dest := eggRects;
  502.                                         OffsetRect(dest, -dest.left, -dest.bottom);
  503.                                         OffsetRect(dest, tombRects[4].left + anotherNumber, tombRects[4].top);
  504.                                     end
  505.                                 else
  506.                                     begin
  507.                                         dest := eggRects;
  508.                                         OffsetRect(dest, -dest.left, -dest.bottom);
  509.                                         OffsetRect(dest, tombRects[2].left + anotherNumber, tombRects[2].top);
  510.                                     end;
  511.                             end;
  512.                         oldDest := dest;
  513.                     end;
  514.         end;
  515.  
  516. {--------------------}
  517.  
  518.         procedure SetUpNonEggEnemies;
  519.             var
  520.                 index: Integer;
  521.         begin            {a normal 'non-egg' wave}
  522.             totalToKill := levelOn div 5 + 4;
  523.             numberOfEnemies := levelOn div 5 + 1;
  524.             if (numberOfEnemies > maxEnemies) then
  525.                 numberOfEnemies := maxEnemies;
  526.             for index := 1 to numberOfEnemies do
  527.                 with theEnemies[index] do
  528.                     begin
  529.                         mode := DoRandom(kInitEnemyModeRange) + kInitEnemyModeMinumum;
  530.                         DoEnemyPlacement(index);
  531.                     end;
  532.         end;
  533.  
  534. {--------------------}
  535.  
  536.     begin
  537.         if (score > 0) then                        {Compute the time bonus (if any) to the score.    }
  538.             aNumber := 2000 - gameCycle        {If they cleared it in less than 2000 cycles        }
  539.         else
  540.             aNumber := 0;
  541.         if (aNumber < 0) then                    {But don't SUBTRACT from their score, even    }
  542.             aNumber := 0;                                    {if they took forever.  Just add zero.}
  543.         score := score + aNumber;                {Add it...                                                }
  544.         ShowScore;
  545.         CheckExtraMortal;
  546.         oldScore := Score;                            {Keep a hold on this score.                }
  547.         levelOn := levelOn + 1;
  548.         ShowLevel;
  549.         if (levelOn = 3) then
  550.             stonesSliding := TRUE
  551.         else
  552.             stonesSliding := FALSE;
  553.  
  554.         with theEye do
  555.             begin
  556.                 otherMode := 0;
  557.                 mode := (levelOn * 10) - 1500;
  558.                 if (mode > -100) then
  559.                     mode := -100;
  560.                 dest := eyeRects[4];
  561.                 CenterZeroRect(dest);
  562.                 if (DoRandom(2) = 0) then
  563.                     OffsetRect(dest, 320, upperEyeHeight)
  564.                 else
  565.                     OffsetRect(dest, 320, lowerEyeHeight);
  566.                 oldDest := dest;
  567.             end;
  568.  
  569.         beastsActive := 0;
  570.         beastsKilled := 0;
  571.  
  572.         if ((levelOn div 5) = (levelOn / 5)) then
  573.             SetUpEggEnemies
  574.         else
  575.             SetUpNonEggEnemies;
  576.  
  577.         for index := 1 to numberOfEnemies do
  578.             with theEnemies[index] do
  579.                 begin
  580.                     state := FALSE;
  581.                     aNumber := DoRandom(levelOn);    {What type of sphinx?  O, 1 or 2?  Well, on level 1,}
  582.                     if (aNumber > 20) then                {there is a 0% chance that a random # between 0 &}
  583.                         otherMode := 2                            {0 will be greater than 20...so, no tough sphinx.}
  584.                     else                                                    {But on level 30, aNumber will be a random number}
  585.                         begin                                                {between 0 and 29.  That gives us almost a 33%}
  586.                             if (aNumber > 5) then        {chance that it will be a sphinx 2, if not a sphinx 2,}
  587.                                 otherMode := 1                    {(not >20) then a good 50% chance that aNumber>10}
  588.                             else                                            {(11 to 20) and thus a sphinx 1.  Note: there is}
  589.                                 otherMode := 0;                    {ALWAYS a CHANCE of the easiest sphinx 0, but it}
  590.                         end;                                                {gets increasingly unlikely as the player goes on.}
  591.                     vertVel := 0;
  592.                     horiVel := 0;
  593.                 end;
  594.  
  595.         with theHand do
  596.             begin
  597.                 dest := handRects[0];
  598.                 OffsetRect(dest, -dest.left, -dest.top);
  599.                 OffsetRect(dest, handLeft, handBottom);
  600.                 oldDest := dest;
  601.                 state := FALSE;
  602.                 onward := FALSE;
  603.                 mode := 0;
  604.             end;
  605.  
  606.         growRate := levelOn div 3 + 1;
  607.         if (growRate > 8) then
  608.             growRate := 8;
  609.         numberOfStones := 2;
  610.         startStone := 0;
  611.         if (levelOn < 3) then
  612.             tombRects[0] := tombRects[-1]
  613.         else
  614.             tombRects[0] := tombRects[-2];
  615.  
  616.         if (levelOn = 3) then
  617.             begin
  618.                 tombRects[5] := tombRects[-4];
  619.                 numberOfStones := numberOfStones + 2;
  620.             end
  621.         else
  622.             tombRects[5] := tombRects[-3];
  623.  
  624.         if (((levelOn + 4) / 5) = ((levelOn + 4) div 5)) then
  625.             numberOfStones := numberOfStones + 3;
  626.         if ((levelOn / 5) = (levelOn div 5)) then
  627.             numberOfStones := numberOfStones + 3;
  628.         if (((levelOn + 3) / 5) = ((levelOn + 3) div 5)) then
  629.             numberOfStones := numberOfStones + 2;
  630.         if (((levelOn + 2) / 5) = ((levelOn + 2) div 5)) then
  631.             numberOfStones := numberOfStones + 2;
  632.         RedoTheBackground;
  633.         gameCycle := 0;
  634.         FlushEvents(everyEvent, 0);
  635.     end;
  636.  
  637. {=================================}
  638.  
  639.     procedure EnterANewMortal;
  640.         var
  641.             halfHeight: Integer;
  642.     begin
  643.         with thePlayer do
  644.             begin
  645.                 facing := 0;
  646.                 mode := 0;
  647.                 horiVel := 0;
  648.                 vertVel := 0;
  649.                 dest := playerRects[facing, mode];
  650.                 CenterZeroRect(dest);
  651.                 halfHeight := (dest.bottom - dest.top) div 2;
  652.                 OffSetRect(dest, 320, 425 - halfHeight);
  653.                 oldDest := dest;
  654.                 if (theEye.mode > 0) then
  655.                     theEye.mode := 272;
  656.                 state := FALSE;
  657.             end;
  658.         keyStillDown := FALSE;
  659.         playing := TRUE;
  660.         pausing := FALSE;
  661.         deadAndGone := FALSE;
  662.         AnimateTheAnk;
  663.     end;
  664.  
  665. {===================================}
  666.  
  667.     procedure DoEnd;
  668.         var
  669.             index: Integer;
  670.             dummyLong: LongInt;
  671.             tempRect: Rect;
  672.     begin
  673.         DoTheSound('music.snd', highPriority);                    {Play the theme song, but wait for it to finish    }
  674.         playing := FALSE;
  675.         pausing := FALSE;
  676.         RedoTheBackground;
  677.         ShowScore;
  678.         tempRect := gameoverRects;
  679.         CenterZeroRect(tempRect);
  680.         OffsetRect(tempRect, 320, 120);
  681.         for index := 1 to 5 do
  682.             begin
  683.                 CopyMask(BitMapPtr(objectCPtr^.portPixMap^)^, offMaskMap, mainWndo^.portBits, gameoverRects, gameoverRects, tempRect);
  684.                 Delay(4, dummyLong);
  685.                 CopyMask(BitMapPtr(objectCPtr^.portPixMap^)^, offMaskMap, mainWndo^.portBits, gameoverRects, gameoverRects, tempRect);
  686.                 Delay(4, dummyLong);
  687.             end;
  688.  
  689.         with theEye do
  690.             begin
  691.                 dest := eyeRects[4];
  692.                 CenterZeroRect(dest);
  693.                 OffsetRect(dest, 320, upperEyeHeight);
  694.                 oldDest := dest;
  695.             end;
  696.  
  697.         repeat
  698.         until (soundPriority = noSound);
  699.  
  700.         InitCursor;
  701.         FinalScore;
  702.         RedoTheBackground;
  703.         RedrawHiScores;
  704.  
  705.         EnableItem(GetMenu(mGame), iBegin);
  706.         DisableItem(GetMenu(mGame), iPause);
  707.         DisableItem(GetMenu(mGame), iEnd);
  708.         DrawMenuBar;                    {Draw the menu bar}
  709.     end;
  710.  
  711. {=================================}
  712.  
  713.     procedure ExitAMortal;
  714.         var
  715.             aNumber: Integer;
  716.     begin
  717.         mortals := mortals - 1;
  718.         ShowMortals;
  719.         UnionRect(thePlayer.oldDest, thePlayer.dest, thePlayer.wholeRect);
  720.         CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, thePlayer.wholeRect, thePlayer.wholeRect, srcCopy, playRgn);
  721.         if (mortals <= 0) then                            {Game over, dude}
  722.             begin
  723.                 DoEnd;
  724.             end
  725.         else
  726.             begin
  727.                 EnterANewMortal;
  728.             end;
  729.     end;
  730.  
  731. {=================================}
  732.  
  733.     procedure SlideTheStones;
  734.         var
  735.             leftExposed, rightExposed: Rect;
  736.     begin
  737.         leftExposed := tombRects[6];
  738.         OffsetRect(tombRects[6], -1, 0);
  739.         leftExposed.left := tombRects[6].right;
  740.  
  741.         rightExposed := tombRects[5];
  742.         OffsetRect(tombRects[5], 1, 0);
  743.         rightExposed.right := tombRects[5].left;
  744.  
  745.         CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, BitMapPtr(loadCPtr^.portPixMap^)^, leftExposed, leftExposed, srcCopy, nil);
  746.         CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, BitMapPtr(loadCPtr^.portPixMap^)^, rightExposed, rightExposed, srcCopy, nil);
  747.         CopyBits(BitMapPtr(objectCPtr^.portPixMap^)^, BitMapPtr(loadCPtr^.portPixMap^)^, longStoneSrc, tombRects[6], srcCopy, nil);
  748.         CopyBits(BitMapPtr(objectCPtr^.portPixMap^)^, BitMapPtr(loadCPtr^.portPixMap^)^, longStoneSrc, tombRects[5], srcCopy, nil);
  749.  
  750.         leftExposed.left := 0;
  751.         rightExposed.right := 640;
  752.         CopyBits(BitMapPtr(loadCPtr^.portPixMap^)^, mainWndo^.portBits, leftExposed, leftExposed, srcCopy, playRgn);
  753.         CopyBits(BitMapPtr(loadCPtr^.portPixMap^)^, mainWndo^.portBits, rightExposed, rightExposed, srcCopy, playRgn);
  754.  
  755.         if (tombRects[6].right < 0) then
  756.             begin
  757.                 tombRects[5] := tombRects[-3];
  758.                 tombRects[6] := tombRects[-5];
  759.                 numberOfStones := numberOfStones - 2;
  760.                 stonesSliding := FALSE;
  761.             end;
  762.     end;
  763.  
  764. {=================================}
  765.  
  766. end.